package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhUserMoney;
import com.ruoyi.xh.service.IXhUserMoneyService;

/**
 * 余额变更Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "余额变更Controller",value = "余额变更Controller")
@RestController
@RequestMapping("/xh/userMoney")
public class XhUserMoneyController extends BaseController {

    @Autowired
    private IXhUserMoneyService xhUserMoneyService;

    /**
     * 查询余额变更列表
     */
    @PreAuthorize("@ss.hasPermi('xh:userMoney:list')")
    @GetMapping("/list")
    @ApiOperation("查询余额变更列表")
    public TablePageDataInfo<XhUserMoney> list(XhUserMoney xhUserMoney) {
        return TablePageDataInfo.success(xhUserMoneyService.selectXhUserMoneyList(xhUserMoney));
    }

    /**
     * 获取余额变更详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:userMoney:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取余额变更详细信息")
    public CommentResult<XhUserMoney> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhUserMoneyService.selectXhUserMoneyById(id));
    }

    /**
     * 新增余额变更
     */
    @PreAuthorize("@ss.hasPermi('xh:userMoney:add')")
    @Log(title = "余额变更", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增余额变更")
    public CommentResult<XhUserMoney> add(@RequestBody XhUserMoney xhUserMoney) {
            xhUserMoneyService.insertXhUserMoney(xhUserMoney);
        return CommentResult.success();
    }

    /**
     * 修改余额变更
     */
    @PreAuthorize("@ss.hasPermi('xh:userMoney:edit')")
    @Log(title = "余额变更", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改余额变更")
    public CommentResult<XhUserMoney> edit(@RequestBody XhUserMoney xhUserMoney) {
            xhUserMoneyService.updateXhUserMoney(xhUserMoney);
        return CommentResult.success();
    }

    /**
     * 删除余额变更
     */
    @PreAuthorize("@ss.hasPermi('xh:userMoney:remove')")
    @Log(title = "余额变更", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除余额变更")
    public CommentResult<XhUserMoney> remove(@PathVariable Long[] ids) {
            xhUserMoneyService.deleteXhUserMoneyByIds(ids);
        return CommentResult.success();
    }
}
